#!/usr/bin/env python
# coding=UTF-8

def check( test, pattern):
    result, sign = '', ''
    if ( test == pattern ):
        result = "PASSED"
        sign = '=='
    else:
        result = "FAILED"
        sign = "!="
        
    print result, test, sign, pattern


def whatIsTheResultString():
    a = 'Comp''Sci'
    b = 'Computer'+'Science'
    c = 'H2O'*3
    d = 'CO2'*0

    check( a, 'CompSci' )
    check( b, 'ComputerScience' )
    check( c, 'H2OH2OH2O')
    check( d, '' )

    
def putCorrectQuotationMarks():
    # They'll hibernate during the winter.
    print "They'll hibernate during the winter."
    print 'They\'ll hibernate during the winter.'
    
    # "Absolutely not," he said.
    print '"Absolutely not," he said.'
    print "\"Absolutely not,\" he said."
    
    # "He said, 'Absolutely not,'" recalled Mel.
    print "\"He said, 'Absolutely not,'\" recalled Mel."
    print '''"He said, 'Absolutely not,'" recalled Mel.'''
    
    # hydrogen sulfide
    print 'hydrogen sulfide'
    
    # left\right
    print 'left\\right'


def rewriteStringUsingSingleOrDoubleQuotes():
    pattern = '''A
B
C'''
    check( pattern, 'A\nB\nC' )
    check( pattern, "A\nB\nC" )
    

def useLenFunctionToFindTheLengthOfEmptyString():
    emptyStr = ''
    length = len(emptyStr)
    check( length, 0 )
    
    someStr = 'abc'
    if len(someStr):
        print someStr
    
    
def printMessagesUsingVariables():
    x = 3
    y = 12.5
    
    # The rabbit is 3.
    print 'The rabbit is %d.' % x
    print 'The rabbit is {0}.'.format(x)
    
    # The rabbit is 3 years old.
    print 'The rabbit is', x, 'years old.'
    print 'The rabbit is %d years old.' % x
    
    # 12.5 is average.
    print y, 'is average.'
    print '%.1f is average.' % y
    
    # 12.5 * 3
    print y, '*', x
    print '%.1f * %d' % ( y, x )
    print '{0} * {1}'.format( y, x )
    
    # 12.5 * 3 is 37.5
    print y, '*', x, 'is', y*x 
    print '%.1f * %d is %.1f' % ( y, x, y*x )
   
        
def evaluateExpression():
    check( 'g' == "g", True )
    check( 'g' == 'G', False )
    check( 'a' >= 'b', False )
    check( 'ant' < 'abc', False )
    check( 'ant' > 'Ant', True )
    check( 'ant' > 'Abc', True )
    check( 'ant' < 'anti', True )
    
    
def rawInputOfFloatNumber():
    num = float( raw_input("Please, enter a number: ") )
    print num

    
def main():
    run_tests()


def run_tests():
    """ Runs exercises for strings"""
        
    whatIsTheResultString()
    putCorrectQuotationMarks()
    rewriteStringUsingSingleOrDoubleQuotes()
    useLenFunctionToFindTheLengthOfEmptyString()
    printMessagesUsingVariables()
    evaluateExpression()
    rawInputOfFloatNumber()


if __name__ == "__main__":
    main()